<template>
  <div class="app-container">
    <el-table :data="tableData" class="tableData" style="width: 100%">
      <el-table-column
        type="index"
        label="序号"
        fixed="left"
        align="center"
        :index="table_index"
        width="50"
      ></el-table-column>
      <el-table-column :prop="index" align="center" v-for="(item, index) in head" :key="index" :label="item">
        <template slot-scope="scope">
          <span>{{scope.row[index] | commtable(item)}} </span>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="username" align="center" label="服务商手机号">
        <template slot-scope="scope">
          <span>{{scope.row.username | phonereg}}</span>
        </template>
      </el-table-column>-->
    </el-table>
    <!-- <div v-for="(item, index) in head" :key="index">
      {{ item }} {{index}}
    </div> -->
    <div class="pagesCon">
      <div>
        <el-pagination
          :current-page="params.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="params.pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>
  </div>
</template>

<script>
// import { exportfun } from "@/api/commJs/index";
export default {
  props: {
    total: {
      type: Number,
      default: 0
    },
    tableData: {
      type: Array,
      default: []
    },
    head: {
      type: Object,
      default: {}
    }
  },
  name: "",
  data() {
    return {
      params: {
        page: 1,
        pagesize: 10
      }
    };
  },
  methods: {
    async list() {
      //exportfun  request1 1:get  0:post
      //   let res = await exportfun(
      //     "com.mmk.report.api.AdminReportProvider/1.0.0/exportAllowance.html",
      //     dates,
      //     1
      //   );
    },
    table_index(index) {
      return (this.params.page - 1) * this.params.pagesize + index + 1;
    },
    handleSizeChange(val) {
      this.params.page = 1;
      this.params.pagesize = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.params.page = val;
      this.list();
    }
  }
};
</script>
